home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / ENV Server / server src / hash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-09  |  1.4 KB  |  51 lines  |  [TEXT/ALFA]

  1. /********************************************************
  2. *                                                       *
  3. *  hash.h                                               *
  4. *                                                       *
  5. *  header for the hash table routines.                  *
  6. *  The only module that                                 *
  7. *  should be using this file is the symbol.[ch] module. *
  8. *                                                       *
  9. ********************************************************/
  10.  
  11. #ifndef HASH_H
  12. #define HASH_H
  13.  
  14.  
  15. /********************************************/
  16. /* macros for sizes and errors **************/
  17. /********************************************/
  18. #define HASH_SIZE   211
  19.  
  20. #define H_NOERR       0
  21. #define H_ERROR       1
  22.  
  23. typedef struct _hash_node {
  24.   char    *name;                /* environment variable name */
  25.   char  *value;               /* environment variable value */
  26.   int    key;                  /* search key of this item    */
  27.   struct _hash_node *next_node;
  28. } HashNode, *HashNodePtr;
  29.  
  30.  
  31. typedef HashNodePtr Buckets[HASH_SIZE];
  32.  
  33. typedef struct _hash_table {
  34.     int         last_key;    /* info for last node accessed/retrieved */
  35.     HashNodePtr last_node;
  36.     Buckets     buckets;
  37. } HashTable, *HashTablePtr;
  38.  
  39. /******************
  40. **   functions
  41. ******************/
  42.  
  43. int          hash_add_entry( char*);   /* returns F/T for success/failure */
  44. HashNodePtr  hash_get_entry( char*);   /* fetch the info */
  45.  
  46. #endif /* HASH_H */
  47.  
  48.  
  49.  
  50.  
  51.